package org.esjsoftware.v2m.rim.util.datastorage.rms;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;

public class Appointment {
	private int int1;
	private int int2;
	private long long1;
	private String str1;
	private String str2;
	private String str3;
	private boolean WroteFlag;

	public Appointment() {
	}

	/**
	 * 
	 * @param _int1
	 * @param _int2
	 * @param _long1
	 * @param _str1
	 * @param _str2
	 * @param _str3
	 * @param _WroteFlag
	 */
	public Appointment(int _int1, int _int2, long _long1, String _str1,
			String _str2, String _str3, boolean _WroteFlag) {
		this.int1 = _int1; 
		this.int2 = _int2;
		this.long1 = _long1;
		this.str1 = _str1;
		this.str2 = _str2;
		this.str3 = _str3;
		this.WroteFlag = _WroteFlag;
	}

	/**
	 * 
	 * @param rec
	 */
	public Appointment(byte[] rec) {
		initAppointmnet(rec); 
	}

	/**
	 * 
	 * @return byte[]
	 */
	public byte[] toBytes() {
		byte[] data = null;
		try {
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			DataOutputStream dos = new DataOutputStream(baos);
			dos.writeInt(int1);
			dos.writeInt(int2);
			dos.writeLong(long1);
			dos.writeUTF(str1);
			dos.writeUTF(str2);
			dos.writeUTF(str3);
			dos.writeBoolean(WroteFlag);
			data = baos.toByteArray();
			baos.close();
			dos.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return data;
	}

	/**
	 * 
	 * @param rec
	 */
	public void initAppointmnet(byte[] rec) { 
		ByteArrayInputStream bais = new ByteArrayInputStream(rec);
		DataInputStream dis = new DataInputStream(bais);

		try {
			int1 = dis.readInt();
			int2 = dis.readInt();
			long1 = dis.readLong();
			str1 = dis.readUTF();
			str2 = dis.readUTF();
			str3 = dis.readUTF();
			WroteFlag = dis.readBoolean();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public int getInt1() { 
		return int1;
	}

	public int getInt2() {
		return int2;
	}

	public long getLong1() {
		return long1;
	}

	public String getStr1() {
		return str1;
	}

	public String getStr2() {
		return str2;
	}

	public String getStr3() {
		return str3;
	}

	public boolean getWroteFlag() {
		return WroteFlag;
	}

}
